<template>
    <div style="padding:30px;">
        <el-alert :closable="false" title="">
            <transition name="fade-transform" mode="out-in">
                <template>
                    <div class="dRootCls" :height="iHeight">
                        <div class="div1">
                            <el-tree :data="propArray" :props="defaultProps" show-checkbox
                                @check-change="handleCheckChange">
                            </el-tree>
                        </div>
                        <div class="div2">
                            <div>
                                <EditButton @add="onAdd" @refresh="onRefresh" @search="onSearch" :listData="getList"
                                    :filterFieldName="getFields"></EditButton>
                                <el-table v-loading="listLoading" border :data="list" :height="iHeight"
                                    style="width: 100%">
                                    <el-table-column prop="deviceId" width="100px" label="设备编号">
                                    </el-table-column>
                                    <el-table-column prop="deviceName" label="设备名称">
                                    </el-table-column>
                                    <el-table-column prop="location" label="设备位置">
                                    </el-table-column>
                                    <el-table-column prop="deptIds" width="100px" label="科室ID">
                                    </el-table-column>
                                    <el-table-column prop="roomId" width="80px" label="诊室ID">
                                    </el-table-column>
                                    <el-table-column prop="deviceIp" width="110px" label="设备IP">
                                    </el-table-column>
                                    <el-table-column width="80px" label="设备状态">
                                        <template slot-scope="scope">
                                            <span v-if="scope.row.status == 1" style="font-size: 24px;color:#29ce69;"
                                                class="iconfont icon-zaixian"></span>
                                            <span v-else style="font-size: 24px;color:gray;"
                                                class="iconfont icon-lixian"></span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="最近开机时间">
                                        <template slot-scope="scope">
                                            <span>{{ getDateTime(scope.row.startRunTime) }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="最后关机时间">
                                        <template slot-scope="scope">
                                            <span>{{ getDateTime(scope.row.stopRunTime) }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column fixed="right" label="操作" width="150">
                                        <template slot-scope="scope">
                                            <EditTableButton @click-button="optClick" :attrs="attrs" :data="scope.row">
                                            </EditTableButton>
                                        </template>
                                    </el-table-column>
                                </el-table>
                                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                                    :current-page="currentPage" :page-sizes="[10, 20, 30, 40, 50, 100]"
                                    :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
                                    :total="totalSize">
                                </el-pagination>
                                <el-dialog :visible.sync="editVisible" class="editDialogClass" :close="closed"
                                    :modal-append-to-body="true" :append-to-body="true" :close-on-click-modal="false"
                                    title="设备信息">
                                    <div>
                                        <el-form :model="form" v-if="form != null" label-width="80px">
                                            <el-form-item label="名称">
                                                <el-input :disabled="isDisabled" v-model="form.deviceName" />
                                            </el-form-item>
                                            <el-form-item label="绑定编码">
                                                <el-input :disabled="isDisabled" placeholder="绑定目标设备唯一编码,多个逗号分开"
                                                    v-model="form.deviceBindCode" />
                                            </el-form-item>
                                            <el-form-item label="显示标题">
                                                <el-input :disabled="isDisabled" v-model="form.showTitle"
                                                    placeholder="设备显示标题" />
                                            </el-form-item>
                                            <el-form-item label="设备描述">
                                                <el-input :disabled="isDisabled" type="textarea"
                                                    v-model="form.deviceDesc" placeholder="设备位置或其他说明信息" />
                                            </el-form-item>
                                            <el-form-item label="刷新地址">
                                                <el-input :disabled="isDisabled" v-model="form.refreshUrl"
                                                    placeholder="设备刷新地址" />
                                            </el-form-item>
                                            <el-form-item label="科室">
                                                <el-select :disabled="isDisabled" filterable remote class="elSelect"
                                                    v-model="deptValue" @change="deptChanged" multiple clearable
                                                    placeholder="请选择">
                                                    <el-option v-for="item in deptOptions" :key="item.deptId"
                                                        :label="item.deptName" :value="item.deptId" />
                                                </el-select>
                                            </el-form-item>
                                            <el-form-item label="诊室">
                                                <el-select :disabled="isDisabled" filterable remote class="elSelect"
                                                    v-model="roomValue" @change="layoutChanged" clearable
                                                    placeholder="请选择">
                                                    <el-option v-for="item in roomOptions" :key="item.roomId"
                                                        :label="item.roomName" :value="item.roomId" />
                                                </el-select>
                                            </el-form-item>
                                            <el-form-item label="设备类型">
                                                <el-select :disabled="isDisabled" class="elSelect" width="100%;"
                                                    v-model="typeValue" @change="typeChanged" clearable
                                                    placeholder="请选择">
                                                    <el-option v-for="item in typeOptions" :key="item.typeId"
                                                        :label="item.name" :value="item.typeId" />
                                                </el-select>
                                            </el-form-item>
                                            <el-form-item label="预览" style="width:100%;height:150px; padding:0px;">
                                                <div
                                                    style="width:100%;height:100%;padding:0px;height:150px;color: aliceblue;">
                                                    <div class="yulanRoot"
                                                        :style="{ backgroundColor: colorConfig.backgroundColor, color: colorConfig.textColor }">
                                                        <div
                                                            style="width:100%;flex:1;background-color:rgba(255, 255, 255, 0.2);">
                                                            {{ basicConfig.title }}
                                                        </div>
                                                        <div class="centerClass">
                                                            <div class="leftClass common"
                                                                :style="{ backgroundColor: colorConfig.contentColor }">
                                                                <div class="left_data_class">
                                                                    <div v-for="(item, index) in attrTables"
                                                                        :key="index">
                                                                        {{ item }}</div>
                                                                </div>
                                                            </div>
                                                            <div class="rightClass common"
                                                                :style="{ backgroundColor: colorConfig.contentColor }">
                                                                right</div>
                                                        </div>
                                                        <div
                                                            style="width:100%;flex:1;background-color:rgba(255, 255, 255, 0.2);">
                                                            {{ basicConfig.tips }}
                                                        </div>
                                                    </div>
                                                </div>
                                            </el-form-item>
                                            <el-form-item label="基本信息">
                                                <el-select :disabled="isDisabled" class="elSelect" v-model="basicValue"
                                                    @change="basicChanged" clearable placeholder="请选择">
                                                    <el-option v-for="item in basicOptions" :key="item.basicId"
                                                        :label="item.name" :value="item.basicId" />
                                                </el-select>
                                            </el-form-item>
                                            <el-form-item label="颜色配置">
                                                <el-select :disabled="isDisabled" class="elSelect" v-model="colorValue"
                                                    @change="colorChanged" clearable placeholder="请选择">
                                                    <el-option v-for="item in colorOptions" :key="item.colorId"
                                                        :label="item.name" :value="item.colorId" />
                                                </el-select>
                                            </el-form-item>
                                            <el-form-item label="布局信息">
                                                <el-select :disabled="isDisabled" class="elSelect" v-model="layoutValue"
                                                    @change="layoutChanged" clearable placeholder="请选择">
                                                    <el-option v-for="item in layoutOptions" :key="item.layoutId"
                                                        :label="item.name" :value="item.layoutId" />
                                                </el-select>
                                            </el-form-item>

                                        </el-form>
                                    </div>
                                    <template #footer>
                                        <span class="dialog-footer">
                                            <el-button @click="clickCancel">取消</el-button>
                                            <el-button v-if="!isDisabled" type="primary" @click="clickConfirm">确定
                                            </el-button>
                                        </span>
                                    </template>
                                </el-dialog>
                                <edit-form @sendUpdate="update" ref="editForm"></edit-form>
                                <vioce-edit ref="vioceDialog"></vioce-edit>
                                <call-show-edit ref="callShowEdit"></call-show-edit>
                                <auto-open ref="autoOpen"></auto-open>
                            </div>

                        </div>
                    </div>

                </template>
            </transition>
        </el-alert>
    </div>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import { DevicesModule } from '@/store/modules/device'
import { IDeptModel, IDevice } from '@/api/types';
import EditButton from '@/views/common/edit-button.vue'
import { MessageBox } from 'element-ui'
import EditForm from "@/views/common/edit-form.vue"
import { DeviceTouchType, FormDataUtils, TouchType } from '@/views/common/data/ICommon';
import EditTableButton from "@/views/common/edit-table-button.vue"
import { queueArr } from "@/utils/q"
import VioceEdit from './components/voice-edit.vue';
import CallShowEdit from './components/call-show-edit.vue';
import AutoOpen from './components/auto_open.vue'
import { DeptsModule } from '@/store/modules/dept';

@Component({
    name: 'Device',
    components: {
        EditButton,
        EditForm,
        EditTableButton,
        VioceEdit,
        CallShowEdit,
        AutoOpen
    }
})
export default class extends Vue {
    public allList: Array<IDevice> = [];
    public list: Array<IDevice> = [];
    public pageList: Array<IDevice> = [];

    public listLoading: boolean = false
    public isDisabled: boolean = false
    public iHeight = window.innerHeight - 300;
    public currentPage: number = 1;
    public pageSize: number = 10;
    public totalSize: number = 0;

    public propArray: Array<{
        label: string,
        id: string,
        children: any[]
    }> = []
    public count: number = 0;
    public defaultProps = {
        children: 'children',
        label: 'label'
    }

    public selectArray: Array<string> = [];
    public attrs: Array<string> = ["device.voiceSetting", "device.showSetting", "common.refresh",
        "device.reboot", "device.shutdown", "device.updateApk", "device.setAutoOpen", "common.delete"];//绑定IP

    public colorConfig: any = { backgroundColor: "#1D82E8", contentColor: "#1E55A8", textColor: "#FFFFFF" }
    public basicConfig: any = {}

    public attrShow: boolean = false
    public deptValue = []
    public roomValue: any = ''
    public typeValue: any = ''
    public layoutValue: any = ''
    public colorValue: any = ''
    public basicValue: any = ''
    public attrValue: any = ''

    public deptOptions: any = []
    public roomOptions: any = []
    public typeOptions: any = []
    public attrTables: any = [];
    public layoutOptions: any = [];
    public basicOptions: any = [];
    public colorOptions: any = [];
    public attrOptions: any = [];

    public form: any = {};
    public editVisible: boolean = false;
    scope: any;

    $refs: any
    public optType: string = "";
    public cur: any

    // public arr = getQueue()
    public qArr = queueArr();

    mounted() {
        // console.error(queue);
    }
    created() {
        this.init()
    }

    public getList() {
        return this.allList;
    }

    public getDateTime(milliseconds: number) {
        if (!milliseconds) {
            return "无";
        }
        var date = new Date(milliseconds * 1000);  // 参数需要毫秒数，所以这里将秒数乘于 1000
        let Y = date.getFullYear() + '-';
        let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
        let D = date.getDate() + ' ';
        let h = date.getHours() + ':';
        let m = date.getMinutes() + ':';
        let s = date.getSeconds();
        return Y + M + D + h + m + s;
    }

    public setShowList() {
        let startIndex = this.pageSize * (this.currentPage - 1);
        this.list = this.treeData.filter((value: any, index: any) => {
            return index >= startIndex && index < startIndex + this.pageSize;
        });
    }

    public getFields() {
        return "deviceName,deviceIp,deviceBindCode,roomId,deviceId"
    }

    public typeChanged(val: any) {
        console.error("选择变化:", val);
        this.typeValue = val;
        this.attrShow = val <= 3;
        if (this.attrShow && this.form && this.form.deviceAttr) {
            let attrs = this.form.deviceAttr.attrs.split(",");
            this.attrTables = attrs;
        } else {
            this.attrTables = [];
        }
    }

    public deptChanged(val: any) {
        console.error(val);
        this.roomValue = "";
        let arr = [];
        if (val.length) {
            for (let i = 0; i < val.length; i++) {
                for (let j = 0; j < this.deptOptions.length; j++) {
                    if (this.deptOptions[j].deptId == val[i]) {
                        if (this.deptOptions[j].rooms) {
                            arr.push(...this.deptOptions[j].rooms);
                        }
                    }
                }
            }
        }
        this.roomOptions = arr;
    }

    public layoutChanged(val: any) {
        console.error("选择变化:", val, this.layoutValue, this.deptValue);
    }

    public attrChanged(val: any) {
        console.error("选择变化:", val);
        this.attrOptions.forEach((e: any) => {
            if (e.attrId === val) {
                this.attrTables = e.attrs.split(",");
            }
        });
    }

    //基本配置选择切换
    public basicChanged = (val: any) => {
        let arr: any = this.basicOptions;
        if (arr && arr.length) {
            arr.forEach((value: any) => {
                if (value.basicId === val) {
                    this.basicConfig = value;
                }
            });
        }
    }
    //颜色配置选择切换
    public colorChanged(val: any) {
        let arr: any = this.colorOptions;
        if (arr && arr.length) {
            arr.forEach((value: any) => {
                if (value.colorId === val) {
                    this.colorConfig = value;
                }
            });
        }
    }

    public closed() {
        this.colorConfig = { backgroundColor: "#1D82E8", contentColor: "#1E55A8", textColor: "#FFFFFF" }
        this.basicConfig = { title: "测试标题", tips: "温馨提示:测试信息" };
    }

    public clickCancel() {
        this.editVisible = false;
        this.form = null;
    }

    public clickConfirm() {
        let device: IDevice = this.form
        device.deviceLayoutId = this.layoutValue
        device.deviceColorId = this.colorValue
        device.deviceTypeId = this.typeValue
        device.basicId = this.basicValue
        device.attrId = this.attrValue;

        let deptArr: Array<string> = this.deptValue;
        device.deptIds = deptArr ? deptArr.join(",") : "";
        device.roomId = this.roomValue;
        if (device.roomId) {
            this.roomOptions.forEach((element: any) => {
                if (element.roomId == device.roomId) {
                    device.roomName = element.roomName;
                }
            });
        }

        console.error("保存:", device);
        this.editVisible = false;

        DevicesModule.updateDevice(device).then((value: any) => {
            console.error(value)
            if (value > 0) {
                this.updateTree();
            }
        })
    }

    //操作相关处理
    public optClick(type: DeviceTouchType, row: IDevice) {
        if (type == DeviceTouchType.SEE) {//打开新窗口
            let url = row.refreshUrl || "http://192.168.2.37:7003?id=" + row.deviceId + "&speed=2";
            window.open(url, "_blank");
            return;
        }
        if (type == DeviceTouchType.REBOOT) {
            MessageBox.confirm(
                `确定重启${row.deviceName}吗?`,
                '提示',
                {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }
            ).then(() => {
                DevicesModule.reboot(row.deviceId);
            });
            return;
        }
        if (type == DeviceTouchType.SHUTDOWN) {
            MessageBox.confirm(
                `确定关机${row.deviceName}吗?`,
                '提示',
                {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }
            ).then(() => {
                DevicesModule.shutdown(row.deviceId);
            });
            return;
        }
        if (type == DeviceTouchType.SET_AUTO_OPEN) {
            this.$refs.autoOpen.showDialog(row);
        }
        if (type == DeviceTouchType.UPDATE_APK) {//弹一个有输入框的弹窗
            var apkUrl = "app.apk";
            MessageBox.confirm(
                `确定升级${row.deviceName}吗?\n 名称:${apkUrl}`,
                '提示',
                {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }
            ).then(() => {
                DevicesModule.udpateApk({ deviceId: row.deviceId, downUrl: apkUrl });
            });
            return;
        }

        if (type === DeviceTouchType.DELETE) {
            DevicesModule.deleteDevice(row.deviceId).then(v => {
                console.error(v);
                if (v === 1) {
                    this.allList = this.allList.filter(value => {
                        return value.deviceId != row.deviceId;
                    })
                    this.updateTree();
                }
            }).catch(e => {
                console.error(e);
            })
            return;
        }
        this.optType = type;
        if (type == DeviceTouchType.ADD || type == DeviceTouchType.EDIT) {
            this.handleClick(row, type)
        } else if (type == DeviceTouchType.SHOW_SETTING) {//叫号显示配置
            if (row.deviceLayout) {
                row.deviceLayoutId = row.deviceLayout.layoutId;
            }
            if (row.deviceAttr) {
                row.attrId = row.deviceAttr.attrId;
            }
            if (row.deviceColor) {
                row.deviceColorId = row.deviceColor.colorId
            }
            if (row.deviceType) {
                row.deviceTypeId = row.deviceType.typeId
            }
            if (row.basicConfig) {
                row.basicId = row.basicConfig.basicId;
            }
            this.$refs.callShowEdit.showDialog(row);
            // MessageBox.alert("开发中")
        } else if (type == DeviceTouchType.VOICE_SETTING) {//语音配置
            if (row.deviceLayout) {
                row.deviceLayoutId = row.deviceLayout.layoutId;
            }
            if (row.deviceAttr) {
                row.attrId = row.deviceAttr.attrId;
            }
            if (row.deviceColor) {
                row.deviceColorId = row.deviceColor.colorId
            }
            if (row.deviceType) {
                row.deviceTypeId = row.deviceType.typeId
            }
            if (row.basicConfig) {
                row.basicId = row.basicConfig.basicId;
            }
            this.$refs.vioceDialog.showDialog(row);
        } else if (type == DeviceTouchType.REFRESH) {
            this.refresh(row.deviceId);
        } else if (type == DeviceTouchType.SCREENSHOTS) {//截图
            this.screenShots(row.deviceId);
        }
    }

    //点击查看/编辑
    public handleClick(row: any, str: string) {
        console.log(this, row);
        this.form = row;
        this.isDisabled = str === TouchType.SEE
        if (row.deviceColor) {
            this.colorConfig = row.deviceColor;
        }
        if (row.basicConfig) {
            this.basicConfig = row.basicConfig;
        }
        this.layoutValue = row.deviceLayout ? row.deviceLayout.layoutId : "";
        this.typeValue = row.deviceType ? row.deviceType.typeId : "";
        this.basicValue = row.basicConfig ? row.basicConfig.basicId : "";
        this.colorValue = row.deviceColor ? row.deviceColor.colorId : "";
        this.attrValue = row.deviceAttr ? row.deviceAttr.attrId : "";
        this.deptValue = row.deptIds ? row.deptIds.split(",") : "";
        this.roomValue = row.roomId ? row.roomId : "";
        console.error("TAG 初始化:", this.layoutValue, this.typeValue, this.basicValue, this.colorValue, this.attrValue);
        DevicesModule.getDeviceOthersAll().then((value: any) => {
            console.error(value);
            this.layoutOptions = value['layoutConfigs'];
            this.basicOptions = value['basicConfigs'];
            this.typeOptions = value['typeConfigs'];
            this.colorOptions = value['colorConfigs'];
            this.attrOptions = value['attrConfigs'];

            this.deptOptions = value['depts'];
            // this.roomOptions = value['rooms'];
        });
        this.editVisible = true;
    }

    //删除设备
    public async deleteHandler(row: any) {
        console.error("删除", row)
        MessageBox.confirm(
            `确定删除${row.deviceName}吗?`,
            '提示',
            {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }
        ).then(() => {
            console.log("去删除...TODO");
            DevicesModule.deleteDevice(row.deviceId).then(v => {
                console.error(v);
                if (v === 1) {
                    this.list = this.list.filter(value => {
                        return value.deviceId != row.deviceId;
                    })
                }
            }).catch(e => {
                console.error(e);
            })
        })
    }

    //更新成功
    public update(obj: any) {
        console.error(obj, this.optType);
        if (this.optType === TouchType.ADD) {
            DevicesModule.insertDevice(obj).then(v => {
                console.error(v)
                if (v === 1) {//成功了
                    this.allList.push(obj);
                    // this.list.push(obj);
                    this.updateShowList();
                }
            }).catch(ex => {
                console.error(ex);
            })
        }
    }

    public treeData: any = [];
    public depts: any = [];

    public async init() {
        this.list = [];
        this.listLoading = true
        let result: any = await DevicesModule.getDevices()
        // this.list = result
        this.allList = result;
        this.totalSize = this.allList.length;
        if (this.depts.length <= 0) {
            this.depts = await DeptsModule.getDepts();
            // //获取所有的科室
        }

        this.updateTree();

        console.error("数据:", this.propArray);
        // this.setShowList();
        setTimeout(() => {
            this.listLoading = false
        }, 0.5 * 1000)
    }

    public handleSizeChange(val: number) {
        console.log(`每页 ${val} 条`);
        this.pageSize = val;
        this.setShowList();
    }
    public handleCurrentChange(val: number) {
        console.log(`当前页: ${val}`);
        this.currentPage = val;
        this.setShowList();
    }


    public onAdd() {
        this.optType = TouchType.ADD;
        let mod = {
            deviceId: "", // 设备唯一ID/自定义编号或者IP
            deviceName: "",// 设备名称
            deviceDesc: "",// 设备描述
            location: "", // 位置信息
            deviceMac: "", // 设备MAC地址
            deviceIp: "", // 设备当前登录IP地址    
            showTitle: "",//配置要显示名称(内科一诊区,不配置则使用deptids 或者 roomId对应的默认名称)
            refreshUrl: "",//显示的URL地址,后台改变的时候要动态刷新
            deviceBindCode: "",
        }
        let data = FormDataUtils.getForms(mod, "device", (key: string) => {
            return this.$t(key);
        }, [], [])
        this.$refs.editForm.showForm(data, true)
    }
    public refresh(deviceId: string) {
        DevicesModule.refreshDevice(deviceId);
    }
    public screenShots(deviceId: string) {
        DevicesModule.screenshots(deviceId);
    }

    public isLogin = false;
    public loginParams = [
        // {
        //     "method": "EQ00115",
        //     "body": {
        //         "deptCode": "09",
        //         "deptId": "50",
        //         "deptName": "口腔科",
        //         "patientList": [
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "女",
        //                 "idCard": "520181201402025224",
        //                 "outpatientNo": 1703070373,
        //                 "patientId": 2940272,
        //                 "patientName": "王雅琪",
        //                 "registerId": 10515193,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0004",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "女",
        //                 "idCard": "520181201605284824",
        //                 "outpatientNo": 2211230057,
        //                 "patientId": 7766670,
        //                 "patientName": "罗绍毕",
        //                 "registerId": 10515161,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0006",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "女",
        //                 "idCard": "520112197801282824",
        //                 "outpatientNo": 2211230080,
        //                 "patientId": 7766739,
        //                 "patientName": "王燕",
        //                 "registerId": 10515311,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0010",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": 236,
        //                 "doctorName": "李勋峰",
        //                 "gender": "男",
        //                 "idCard": "522422199105051256",
        //                 "outpatientNo": 2211150132,
        //                 "patientId": 7760981,
        //                 "patientName": "张家坤",
        //                 "registerId": 10515216,
        //                 "remark": "初",
        //                 "roomId": 2,
        //                 "roomName": "牙体牙髓修复1",
        //                 "seq": "初0008",
        //                 "state": "0"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "男",
        //                 "idCard": "520181202210180152",
        //                 "outpatientNo": 2211230101,
        //                 "patientId": 7766770,
        //                 "patientName": "余沅桦",
        //                 "registerId": 10515452,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0014",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "女",
        //                 "idCard": "522526200302121424",
        //                 "outpatientNo": 2109260290,
        //                 "patientId": 7235227,
        //                 "patientName": "胡晨晨",
        //                 "registerId": 10515536,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0016",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": 236,
        //                 "doctorName": "李勋峰",
        //                 "gender": "女",
        //                 "idCard": "522525196206055644",
        //                 "outpatientNo": 1507200367,
        //                 "patientId": 2018377,
        //                 "patientName": "李文琴",
        //                 "registerId": 10515273,
        //                 "remark": "初",
        //                 "roomId": 2,
        //                 "roomName": "牙体牙髓修复1",
        //                 "seq": "初0011",
        //                 "state": "0"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "男",
        //                 "idCard": "522525196603088650",
        //                 "outpatientNo": 12845,
        //                 "patientId": 57870,
        //                 "patientName": "齐树清",
        //                 "registerId": 10515736,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0021",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": 236,
        //                 "doctorName": "李勋峰",
        //                 "gender": "男",
        //                 "idCard": "52018120010914211X",
        //                 "outpatientNo": 1910160162,
        //                 "patientId": 27263,
        //                 "patientName": "陈少欣",
        //                 "registerId": 10515354,
        //                 "remark": "初",
        //                 "roomId": 2,
        //                 "roomName": "牙体牙髓修复1",
        //                 "seq": "初0014",
        //                 "state": "0"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "女",
        //                 "idCard": "520181199312304123",
        //                 "outpatientNo": 2102090010,
        //                 "patientId": 7016236,
        //                 "patientName": "郭丽",
        //                 "registerId": 10515821,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0023",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "男",
        //                 "idCard": "522530200206071310",
        //                 "outpatientNo": 2211230160,
        //                 "patientId": 7766971,
        //                 "patientName": "吴端",
        //                 "registerId": 10515873,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0027",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "男",
        //                 "idCard": "522129200012252511",
        //                 "outpatientNo": 2109120246,
        //                 "patientId": 7215412,
        //                 "patientName": "刘雪松",
        //                 "registerId": 10515924,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0029",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "女",
        //                 "idCard": "520181199105102625",
        //                 "outpatientNo": 2106250329,
        //                 "patientId": 7133053,
        //                 "patientName": "李梅",
        //                 "registerId": 10515958,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0032",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "女",
        //                 "idCard": "522121200408220443",
        //                 "outpatientNo": 2211230191,
        //                 "patientId": 7767068,
        //                 "patientName": "周晶晶",
        //                 "registerId": 10516058,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0035",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "女",
        //                 "idCard": "522725200212231229",
        //                 "outpatientNo": 2211230194,
        //                 "patientId": 7767071,
        //                 "patientName": "李雪梅",
        //                 "registerId": 10516088,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0037",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "男",
        //                 "idCard": "522425201007292717",
        //                 "outpatientNo": 2211230195,
        //                 "patientId": 7767049,
        //                 "patientName": "汤凯翔",
        //                 "registerId": 10516113,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0039",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "男",
        //                 "idCard": "522301200406094012",
        //                 "outpatientNo": 2211230221,
        //                 "patientId": 7767094,
        //                 "patientName": "罗荣金",
        //                 "registerId": 10516262,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0042",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "男",
        //                 "idCard": "520181201310225210",
        //                 "outpatientNo": 1904260138,
        //                 "patientId": 4902242,
        //                 "patientName": "李华山",
        //                 "registerId": 10516062,
        //                 "remark": "初",
        //                 "roomId": 2,
        //                 "roomName": "牙体牙髓修复1",
        //                 "seq": "初0028",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "男",
        //                 "idCard": "520111195404101211",
        //                 "outpatientNo": 2210110012,
        //                 "patientId": 7735622,
        //                 "patientName": "黎修章",
        //                 "registerId": 10516233,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0043",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "女",
        //                 "idCard": "520181202110190142",
        //                 "outpatientNo": 2112020304,
        //                 "patientId": 7412593,
        //                 "patientName": "吴子程",
        //                 "registerId": 10516057,
        //                 "remark": "初",
        //                 "roomId": 2,
        //                 "roomName": "牙体牙髓修复1",
        //                 "seq": "初0032",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "女",
        //                 "idCard": "520181199901030829",
        //                 "outpatientNo": 1805260418,
        //                 "patientId": 5035933,
        //                 "patientName": "李易岑",
        //                 "registerId": 10516331,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0048",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "女",
        //                 "idCard": "52250219830805302X",
        //                 "outpatientNo": 2011140042,
        //                 "patientId": 6905229,
        //                 "patientName": "林敏",
        //                 "registerId": 10516251,
        //                 "remark": "初",
        //                 "roomId": 2,
        //                 "roomName": "牙体牙髓修复1",
        //                 "seq": "初0038",
        //                 "state": "0"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "男",
        //                 "idCard": "522724199206283653",
        //                 "outpatientNo": 1812280296,
        //                 "patientId": 5614662,
        //                 "patientName": "于福辉",
        //                 "registerId": 10516309,
        //                 "remark": "初",
        //                 "roomId": 2,
        //                 "roomName": "牙体牙髓修复1",
        //                 "seq": "初0040",
        //                 "state": "0"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "女",
        //                 "idCard": "522325200304022422",
        //                 "outpatientNo": 2211230241,
        //                 "patientId": 7767144,
        //                 "patientName": "王生",
        //                 "registerId": 10516319,
        //                 "remark": "初",
        //                 "roomId": 2,
        //                 "roomName": "牙体牙髓修复1",
        //                 "seq": "初0041",
        //                 "state": "0"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "男",
        //                 "idCard": "520181201612070816",
        //                 "outpatientNo": 2001030330,
        //                 "patientId": 4676766,
        //                 "patientName": "杨博文",
        //                 "registerId": 10516720,
        //                 "remark": "初",
        //                 "roomId": 2,
        //                 "roomName": "牙体牙髓修复1",
        //                 "seq": "初0001",
        //                 "state": "0"
        //             }
        //         ]
        //     }
        // },
        // {
        //     "method": "EQ00115",
        //     "body": {
        //         "deptCode": "09",
        //         "deptId": "50",
        //         "deptName": "口腔科",
        //         "patientList": [
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "女",
        //                 "idCard": "522502195811232128",
        //                 "outpatientNo": 1909100352,
        //                 "patientId": 6460074,
        //                 "patientName": "张应秀",
        //                 "registerId": 10516795,
        //                 "remark": "初",
        //                 "roomId": 421,
        //                 "roomName": "口腔颌面外科",
        //                 "seq": "初0001",
        //                 "state": "1"
        //             },
        //             {
        //                 "callCount": 1,
        //                 "doctorId": null,
        //                 "doctorName": null,
        //                 "gender": "男",
        //                 "idCard": "520181201612070816",
        //                 "outpatientNo": 2001030330,
        //                 "patientId": 4676766,
        //                 "patientName": "杨博文",
        //                 "registerId": 10516720,
        //                 "remark": "初",
        //                 "roomId": 2,
        //                 "roomName": "牙体牙髓修复1",
        //                 "seq": "初0001",
        //                 "state": "0"
        //             }
        //         ]
        //     }
        // },
        // {
        //     method: "EQA0113", body: { "deptCode": "09", "deptId": "50", "deptName": "口腔科", "doctorCode": "000313", "doctorId": "68", "doctorIntro": "李显平，男，口腔科主任，副主任医师，贵州省口腔医学会理事、贵州省口腔医学会牙体牙髓牙周分会常务理事，贵阳市口腔医学会委员，清镇市医学会常务理事，清镇市党外知识分子联合会副会长。1988年毕业于遵义医科大学口腔系，一直从事口腔临床工作，发表论文10余篇，曾到贵阳市口腔医院进修学习口腔正畸专业；口腔全科医生，擅长牙槽外科、口腔种植修复，口腔正畸，并有较丰富的口腔临床经验。", "doctorName": "李显平", "doctorPositional": "副主任医师", "doctoruser": "", "doctorPhoto": "", "locationId": "", "patientList": [{ "callCount": "69", "callTime": "2022-11-11T21:33:19", "gender": "男", "idCard": "522528199710020830", "outpatientNo": 2009250285, "patientId": 6862740, "patientName": "测试1", "registerId": 10495083, "remark": null, "seq": "初0044", "state": 2 }], "roomCode": "004", "roomId": "2", "roomName": "牙体牙髓修复1", "sort": 0 }
        // },
        // { "method": "EQ00151", "body": { "deptCode": "09", "deptId": "1821", "deptName": "眼科", "doctorList": [{ "IP": "172.20.31.52", "doctorCode": "000161", "doctorId": 236, "doctorIntro": "李勋峰，男，口腔科主治医师，1997年毕业于是黔东南技术学校口腔专业，一直从事口腔科临床工作，有丰富的临床工作经验；曾到遵义医学院附属口腔医院进修,发表论文2篇，擅长口腔内科、口腔修复科疾病的诊治，尤其对牙列缺损的诊治积累了丰富的经验。", "doctorName": "李勋峰", "doctorPositional": "主治医师", "photo": null, "professional": null }, { "IP": "172.20.41.10", "doctorCode": "000313", "doctorId": 68, "doctorIntro": "李显平，男，口腔科主任，副主任医师，贵州省口腔医学会理事、贵州省口腔医学会牙体牙髓牙周分会常务理事，贵阳市口腔医学会委员，清镇市医学会常务理事，清镇市党外知识分子联合会副会长。1988年毕业于遵义医科大学口腔系，一直从事口腔临床工作，发表论文10余篇，曾到贵阳市口腔医院进修学习口腔正畸专业；口腔全科医生，擅长牙槽外科、口腔种植修复，口腔正畸，并有较丰富的口腔临床经验。", "doctorName": "李显平", "doctorPositional": "副主任医师", "photo": null, "professional": null }, { "IP": "172.20.31.60", "doctorCode": "000981", "doctorId": 13669, "doctorIntro": "张世超，女，口腔科住院医师，2016年毕业于湖北医药学院，2016年至2019年于贵阳市口腔医院进行为期三年的口腔全科住院医师规范化培训，有丰富的临床工作经验；擅长牙体牙髓疾病的诊治、牙体修复治疗及树脂美学修复。", "doctorName": "张世超", "doctorPositional": "医师", "photo": null, "professional": null }, { "IP": "172.20.31.58", "doctorCode": "000981", "doctorId": 13669, "doctorIntro": "张世超，女，口腔科住院医师，2016年毕业于湖北医药学院，2016年至2019年于贵阳市口腔医院进行为期三年的口腔全科住院医师规范化培训，有丰富的临床工作经验；擅长牙体牙髓疾病的诊治、牙体修复治疗及树脂美学修复。", "doctorName": "张世超", "doctorPositional": "医师", "photo": null, "professional": null }, { "IP": "172.20.31.49", "doctorCode": "000161", "doctorId": 236, "doctorIntro": "李勋峰，男，口腔科主治医师，1997年毕业于是黔东南技术学校口腔专业，一直从事口腔科临床工作，有丰富的临床工作经验；曾到遵义医学院附属口腔医院进修,发表论文2篇，擅长口腔内科、口腔修复科疾病的诊治，尤其对牙列缺损的诊治积累了丰富的经验。", "doctorName": "李勋峰", "doctorPositional": "主治医师", "photo": null, "professional": null }, { "IP": "172.20.31.55", "doctorCode": "000688", "doctorId": 6881, "doctorIntro": "吴维，女，口腔科主治医师，2007年毕业于遵义医科大学，一直从事口腔科临床工作，有丰富的临床工作经验；曾到重庆医科大学附属口腔医院进修学习修复，种植专业；发表论文2篇，擅长口腔修复，口腔种植，口腔内科疾病的诊治，尤其对牙列部分缺失；牙列缺失；牙体种植；前牙缺损，缺失；瓷贴面，瓷嵌体；氟斑牙；着色牙；牙白斑等疾病的诊治积累了丰富的经验。", "doctorName": "吴维", "doctorPositional": "主治医师", "photo": null, "professional": null }, { "IP": "172.20.31.55", "doctorCode": "001490", "doctorId": 14729, "doctorIntro": null, "doctorName": "卢亚", "doctorPositional": "医师", "photo": null, "professional": null }], "roomCode": "004", "roomId": "2", "roomName": "牙体牙髓修复1" } },
        // {
        //     method: "EQ00113", body: { "deptCode": "09", "deptId": "50", "deptName": "口腔科", "doctorCode": "000313", "doctorId": "68", "doctorIntro": "李显平，男，口腔科主任，副主任医师，贵州省口腔医学会理事、贵州省口腔医学会牙体牙髓牙周分会常务理事，贵阳市口腔医学会委员，清镇市医学会常务理事，清镇市党外知识分子联合会副会长。1988年毕业于遵义医科大学口腔系，一直从事口腔临床工作，发表论文10余篇，曾到贵阳市口腔医院进修学习口腔正畸专业；口腔全科医生，擅长牙槽外科、口腔种植修复，口腔正畸，并有较丰富的口腔临床经验。", "doctorName": "李显平", "doctorPositional": "副主任医师", "doctoruser": "", "doctorPhoto": "", "locationId": "", "patientList": [{ "callCount": "1", "callTime": "2022-11-11T21:20:10", "gender": "女", "idCard": "520122199208103022", "outpatientNo": 2007160514, "patientId": 6786112, "patientName": "测试2", "registerId": 10495085, "remark": null, "seq": "初0046", "state": 0 }], "roomCode": "004", "roomId": "2", "roomName": "牙体牙髓修复1", "sort": 0 }
        // },
        // { "method": "EQ00115", "body": { "deptCode": "09", "deptId": "50", "deptName": "口腔科", "patientList": [{ "callCount": 1, "doctorId": null, "doctorName": null, "gender": "女", "idCard": "522525197210014508", "outpatientNo": 1811060216, "patientId": 5540507, "patientName": "张芝菊", "registerId": 10493144, "remark": "初", "roomId": 2, "roomName": "牙体牙髓修复1", "seq": "初0002", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "男", "idCard": "522625199912293315", "outpatientNo": 2211080153, "patientId": 7755796, "patientName": "陈端学", "registerId": 10493862, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0003", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "女", "idCard": "520181199409193327", "outpatientNo": 1902230294, "patientId": 5653381, "patientName": "宋家永", "registerId": 10493081, "remark": "初", "roomId": 2, "roomName": "牙体牙髓修复1", "seq": "初0003", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "女", "idCard": "520181199908030020", "outpatientNo": 2106210161, "patientId": 1335115, "patientName": "毛贵锌", "registerId": 10493853, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0004", "state": "1" }, { "callCount": 1, "doctorId": 236, "doctorName": "李勋峰", "gender": "女", "idCard": "510113201312260126", "outpatientNo": 2112080314, "patientId": 7418380, "patientName": "刘漪房", "registerId": 10493512, "remark": "初", "roomId": 2, "roomName": "牙体牙髓修复1", "seq": "初0002", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "女", "idCard": "510322199304108607", "outpatientNo": 2210270117, "patientId": 7748337, "patientName": "赵靖", "registerId": 10494106, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0005", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "女", "idCard": "510322199512018606", "outpatientNo": 2210270119, "patientId": 7748334, "patientName": "胡瑞娥", "registerId": 10494116, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0006", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "女", "idCard": "520121199009052828", "outpatientNo": 1404290379, "patientId": 1396946, "patientName": "王敏", "registerId": 10494163, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0009", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "女", "idCard": "520121199110085421", "outpatientNo": 1701140218, "patientId": 2887280, "patientName": "蒙娴", "registerId": 10493768, "remark": "初", "roomId": 2, "roomName": "牙体牙髓修复1", "seq": "初0002", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "男", "idCard": "520181199102210815", "outpatientNo": 2211110123, "patientId": 7758091, "patientName": "向应江", "registerId": 10494469, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0004", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "男", "idCard": "522502197503231771", "outpatientNo": 1903140128, "patientId": 5700223, "patientName": "何贵平", "registerId": 10493785, "remark": "初", "roomId": 2, "roomName": "牙体牙髓修复1", "seq": "初0003", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "男", "idCard": "522225199110232893", "outpatientNo": 1809150290, "patientId": 5481315, "patientName": "王利波", "registerId": 10494467, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0005", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "女", "idCard": "520181197709200825", "outpatientNo": 1809140088, "patientId": 5480264, "patientName": "陈永丽", "registerId": 10493170, "remark": "初", "roomId": 2, "roomName": "牙体牙髓修复1", "seq": "初0004", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "女", "idCard": "520181201612050022", "outpatientNo": 2010090720, "patientId": 3304767, "patientName": "吴一诺", "registerId": 10494510, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0006", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "男", "idCard": "522502197503301354", "outpatientNo": 1905090052, "patientId": 5039289, "patientName": "张蛟", "registerId": 10494511, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0008", "state": "1" }, { "callCount": 1, "doctorId": 236, "doctorName": "李勋峰", "gender": "女", "idCard": "520181199102042129", "outpatientNo": 2104120396, "patientId": 7032063, "patientName": "马移仙", "registerId": 10494248, "remark": "初", "roomId": 2, "roomName": "牙体牙髓修复1", "seq": "初0010", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "女", "idCard": "520103199908084847", "outpatientNo": 2110220473, "patientId": 7321068, "patientName": "李筱", "registerId": 10494700, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0014", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "男", "idCard": "522121199910310035", "outpatientNo": 2211030125, "patientId": 7753120, "patientName": "田纵横", "registerId": 10494705, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0016", "state": "1" }, { "callCount": 1, "doctorId": 236, "doctorName": "李勋峰", "gender": "男", "idCard": "522525193902040012", "outpatientNo": 643, "patientId": 1129, "patientName": "杨正明", "registerId": -10493649, "remark": "优", "roomId": 2, "roomName": "牙体牙髓修复1", "seq": "优0001", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "女", "idCard": "522622200104012024", "outpatientNo": 2210080200, "patientId": 7733467, "patientName": "姚登雪", "registerId": 10494745, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0018", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "男", "idCard": "522525195803040016", "outpatientNo": 2104270151, "patientId": 1896686, "patientName": "成文品", "registerId": 10494865, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0025", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "女", "idCard": "520181201407245728", "outpatientNo": 1908230066, "patientId": 6393015, "patientName": "陈琎怡", "registerId": 10494902, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0027", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "男", "idCard": "522422201310053218", "outpatientNo": 2107050556, "patientId": 7144957, "patientName": "赵宇晨", "registerId": 10494971, "remark": "初", "roomId": 421, "roomName": "口腔颌面外科", "seq": "初0028", "state": "1" }, { "callCount": 1, "doctorId": 236, "doctorName": "李勋峰", "gender": "男", "idCard": "522725199102243514", "outpatientNo": 1809030657, "patientId": 5426443, "patientName": "张正杰", "registerId": 10494845, "remark": "初", "roomId": 2, "roomName": "牙体牙髓修复1", "seq": "初0040", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "男", "idCard": "52232420010316521X", "outpatientNo": 2110050016, "patientId": 7259999, "patientName": "胡青贤", "registerId": 10493177, "remark": "初", "roomId": 2, "roomName": "牙体牙髓修复1", "seq": "初0041", "state": "1" }, { "callCount": 1, "doctorId": null, "doctorName": null, "gender": "男", "idCard": "522528199710020830", "outpatientNo": 2009250285, "patientId": 6862740, "patientName": "测试1", "registerId": 10495083, "remark": "初", "roomId": 2, "roomName": "牙体牙髓修复1", "seq": "初0044", "state": "1" }, { "callCount": 1, "doctorId": 68, "doctorName": "李显平", "gender": "女", "idCard": "520122199208103022", "outpatientNo": 2007160514, "patientId": 6786112, "patientName": "测试2", "registerId": 10495085, "remark": "初", "roomId": 2, "roomName": "牙体牙髓修复1", "seq": "初0046", "state": "0" }, { "callCount": 1, "doctorId": 236, "doctorName": "李勋峰", "gender": "男", "idCard": "522525193902040012", "outpatientNo": 643, "patientId": 1129, "patientName": "杨正明", "registerId": 10493649, "remark": "回", "roomId": 2, "roomName": "牙体牙髓修复1", "seq": "回0001", "state": "0" }] } }
        ,
        {
            "method": "EQ00115", "body": {
                "deptCode": "09", "deptId": "1821", "deptName": "口腔科", "patientList":
                    [{
                        "callCount": 1, "doctorId": null, "doctorName": null, "gender": "女", "idCard": "522525197210014508",
                        "outpatientNo": 1811060216, "patientId": 5540507, "patientName": "张芝菊", "registerId": 10493144, "remark": "初",
                        "roomId": 25, "roomName": "眼科", "seq": "初0002", "state": "0"
                    },
                    {
                        "callCount": 1, "doctorId": null, "doctorName": null, "gender": "男", "idCard": "522625199912293315", "outpatientNo": 2211080153,
                        "patientId": 7755796, "patientName": "陈端学", "registerId": 10493862, "remark": "初", "roomId": 25, "roomName": "眼科", "seq": "初0003", "state": "0"
                    },
                    ]
            }
        },

        // { "method": "EQ00151", "body": { "IP": "172.20.31.42", "locationId": "二椅位", "deptId": "50", "deptCode": "09", "deptName": "口腔科", "roomId": "444", "roomCode": "079", "roomName": "正畸诊室", "RY": "1684", "ZT": "0", "doctorList": [] } },
        // {
        //     method: "EQ00151", body: {
        //         IP: "172.20.31.60", RY: "85", ZT: "1", deptCode: "07", deptId: "50", deptName: "口腔科",
        //         doctorList: [{
        //             doctoIntro: "吴维 1992年毕业于遵义医科大学，贵州省中西医结合学会耳鼻咽喉专业委员会常务委员，贵州省耳鼻咽喉头颈外科学会委员，一直从事耳鼻咽喉科临床工作，有丰富的临床经验；曾先后到贵州医科大学附属医院、遵义医科大学附属医院进修，发表学术论文14篇，擅长耳鼻咽喉科疾病的诊治，尤其对鼻窦炎、慢性咽喉炎疾病的诊治积累了丰富的经验。",
        //             doctorCode: "000688", doctorId: 6881, doctorName: "吴维", doctorPositional: "主任医师", ip: "172.20.31.60",
        //         }], locationId: "", "roomCode": "004", "roomId": "2", roomName: "牙体牙髓修复1"
        //     }
        // },
        // {
        //     "method": "EQ00151", "body": {
        //         "IP": "172.20.11.59", "RY": "12369", "ZT": "1", "deptCode": "06", "deptId": "47",
        //         "deptName": "儿科", "doctorList": [{
        //             "doctoIntro": "杨锦，女，儿科副任医师，2006年毕业于贵阳医学院临床医学专业，一直从事儿科临床工作，有丰富的临床工作经验；曾先后到遵义医学院附属医院儿科、重庆医科大学附属儿童医院PICU进修学习，擅长儿科临床疾病的诊治,尤其对儿科呼吸系统疾病诊治、急危重症救治有丰富的临床经验。", "doctorCode": "002010", "doctorId": 12369, "doctorName": "杨锦", "doctorPositional": "副主任医师", "ip": "172.20.11.59",
        //             "photo": ""
        //         }], "locationId": "", "roomCode": "065", "roomId": "341", "roomName": "儿科急诊室1"
        //     }
        // }
    ]


    public isDepts = false;
    public depts1 = [{
        "method": "EQ00115",
        "body": {
            "deptCode": "06",
            "deptId": "50",
            "deptName": "儿科",
            "patientList": [
                {
                    "callCount": 1,
                    "doctorId": 1382,
                    "doctorName": "康丽妮",
                    "gender": "男",
                    "idCard": "52052220180807153X",
                    "outpatientNo": 2010140391,
                    "patientId": 6658468,
                    "patientName": "田宇航",
                    "registerId": 10487281,
                    "remark": "初",
                    "roomId": 444,
                    "roomName": "正畸诊室",
                    "seq": "初0002",
                    "state": "0"
                },
                {
                    "callCount": 1,
                    "doctorId": 14729,
                    "doctorName": "卢亚",
                    "gender": "男",
                    "idCard": "522423199301215314",
                    "outpatientNo": 2211070246,
                    "patientId": 7755108,
                    "patientName": "胡思贵",
                    "registerId": 10487075,
                    "remark": "初",
                    "roomId": 27,
                    "roomName": "牙体牙髓修复2",
                    "seq": "初0017",
                    "state": "0"
                },
                {
                    "callCount": 1,
                    "doctorId": null,
                    "doctorName": null,
                    "gender": "男",
                    "idCard": "522423194611288612",
                    "outpatientNo": 1909200053,
                    "patientId": 6485230,
                    "patientName": "陈明华",
                    "registerId": 10486447,
                    "remark": "初",
                    "roomId": 641,
                    "roomName": "口腔科专家诊室",
                    "seq": "初0011",
                    "state": "0"
                },
                {
                    "callCount": 1,
                    "doctorId": 68,
                    "doctorName": "李显平",
                    "gender": "女",
                    "idCard": "52018119520110522X",
                    "outpatientNo": 2010210303,
                    "patientId": 2050127,
                    "patientName": "杨继荣",
                    "registerId": 10486892,
                    "remark": "初",
                    "roomId": 641,
                    "roomName": "口腔科专家诊室",
                    "seq": "初0006",
                    "state": "0"
                },
                {
                    "callCount": 1,
                    "doctorId": null,
                    "doctorName": null,
                    "gender": "男",
                    "idCard": "50022219941127681X",
                    "outpatientNo": 2203160552,
                    "patientId": 7568469,
                    "patientName": "张其波",
                    "registerId": 10486899,
                    "remark": "初",
                    "roomId": 641,
                    "roomName": "口腔科专家诊室",
                    "seq": "初0010",
                    "state": "0"
                },
                {
                    "callCount": 1,
                    "doctorId": null,
                    "doctorName": null,
                    "gender": "女",
                    "idCard": "522425196504082426",
                    "outpatientNo": 1508180450,
                    "patientId": 2058787,
                    "patientName": "刘相芬",
                    "registerId": 10487687,
                    "remark": "初",
                    "roomId": 2,
                    "roomName": "牙体牙髓修复1",
                    "seq": "初0020",
                    "state": "0"
                },
                {
                    "callCount": 1,
                    "doctorId": null,
                    "doctorName": null,
                    "gender": "男",
                    "idCard": "522529200007295017",
                    "outpatientNo": 1809160102,
                    "patientId": 5007426,
                    "patientName": "罗豪",
                    "registerId": 10487688,
                    "remark": "初",
                    "roomId": 2,
                    "roomName": "牙体牙髓修复1",
                    "seq": "初0021",
                    "state": "0"
                }
            ]
        }
    }, {
        "method": "EQ00115",
        "body": {
            "deptCode": "06",
            "deptId": "45",
            "deptName": "产科",
            "patientList": [
                {
                    "callCount": 1,
                    "doctorId": 1382,
                    "doctorName": "康丽妮",
                    "gender": "男",
                    "idCard": "52052220180807153X",
                    "outpatientNo": 2010140391,
                    "patientId": 6658468,
                    "patientName": "田宇航",
                    "registerId": 10487281,
                    "remark": "初",
                    "roomId": 444,
                    "roomName": "产科诊室1",
                    "seq": "初0002",
                    "state": "0"
                },
                {
                    "callCount": 1,
                    "doctorId": 14729,
                    "doctorName": "卢亚",
                    "gender": "男",
                    "idCard": "522423199301215314",
                    "outpatientNo": 2211070246,
                    "patientId": 7755108,
                    "patientName": "aaxxx",
                    "registerId": 10487075,
                    "remark": "初",
                    "roomId": 27,
                    "roomName": "产科诊室2",
                    "seq": "初0017",
                    "state": "0"
                },
                {
                    "callCount": 1,
                    "doctorId": null,
                    "doctorName": null,
                    "gender": "男",
                    "idCard": "522423194611288612",
                    "outpatientNo": 1909200053,
                    "patientId": 6485230,
                    "patientName": "陈明华",
                    "registerId": 10486447,
                    "remark": "初",
                    "roomId": 641,
                    "roomName": "产科诊室1",
                    "seq": "初0011",
                    "state": "0"
                },
                {
                    "callCount": 1,
                    "doctorId": 68,
                    "doctorName": "李显平",
                    "gender": "女",
                    "idCard": "52018119520110522X",
                    "outpatientNo": 2010210303,
                    "patientId": 2050127,
                    "patientName": "杨继荣",
                    "registerId": 10486892,
                    "remark": "初",
                    "roomId": 641,
                    "roomName": "产科诊室1",
                    "seq": "初0006",
                    "state": "0"
                },
                {
                    "callCount": 1,
                    "doctorId": null,
                    "doctorName": null,
                    "gender": "男",
                    "idCard": "50022219941127681X",
                    "outpatientNo": 2203160552,
                    "patientId": 7568469,
                    "patientName": "张其波",
                    "registerId": 10486899,
                    "remark": "初",
                    "roomId": 641,
                    "roomName": "产科诊室2",
                    "seq": "初0010",
                    "state": "0"
                },
                {
                    "callCount": 1,
                    "doctorId": null,
                    "doctorName": null,
                    "gender": "女",
                    "idCard": "522425196504082426",
                    "outpatientNo": 1508180450,
                    "patientId": 2058787,
                    "patientName": "刘相芬",
                    "registerId": 10487687,
                    "remark": "初",
                    "roomId": 2,
                    "roomName": "产科诊室2",
                    "seq": "初0020",
                    "state": "0"
                },
                {
                    "callCount": 1,
                    "doctorId": null,
                    "doctorName": null,
                    "gender": "男",
                    "idCard": "522529200007295017",
                    "outpatientNo": 1809160102,
                    "patientId": 5007426,
                    "patientName": "罗豪",
                    "registerId": 10487688,
                    "remark": "初",
                    "roomId": 2,
                    "roomName": "产科诊室2",
                    "seq": "初0021",
                    "state": "0"
                }
            ]
        }
    }]

    //顶部刷新数据
    public onRefresh() {
        // if (this.loginParams.length > 0) {
        //     var l = this.loginParams.shift();
        //     if (l) {
        //         DevicesModule.testService(l).then(v => {
        //             console.error(v);
        //         })
        //     }
        //     return;
        // }
        // if (this.depts.length > 0) {
        //     let d = this.depts.shift();
        //     if (d) {
        //         DevicesModule.testService(d).then(v => {
        //             console.error(v);
        //         })
        //     }
        //     return;
        // }
        // //let p = { "method": "EQ00114", "body": { "deptCode": "07", "deptId": "50", "deptName": "耳鼻喉科", "doctorCode": "", "doctorId": "14729", "doctorName": "卢亚", "idCard": "511028201503018017", "outpatientNo": "1904230201", "patientId": "5823266", "patientName": "曾军诚", "registerId": "10487752", "roomCode": "", "roomId": "27", "roomName": "耳鼻咽喉科诊室", "seq": "初0001" } }
        // let data = this.qArr.shift();
        // if (!data) return;
        // let v = {
        //     "method": "EQ00113",
        //     "body": data
        // }
        // DevicesModule.testService(v).then(v => {
        //     console.error(v);
        // })
    }

    public onSearch(val: any) {
        // this.list = val
    }

    public changetime: any;

    handleCheckChange(data: any, checked: any, indeterminate: any) {
        if (checked) {
            this.selectArray.push(data.id);
        } else {
            let ix = this.selectArray.indexOf(data.id)
            if (ix > -1) {
                this.selectArray.splice(ix, 1);
            }
        }
        this.changetime && clearTimeout(this.changetime);
        this.changetime = setTimeout(() => {
            this.updateShowList();
        }, 800);
    }


    private updateShowList() {
        //更新列表显示
        this.treeData = [];
        if (this.selectArray.length <= 0) {
            this.currentPage = 1;
            this.setShowList();
            return;
        }
        for (let i = 0; i < this.allList.length; i++) {
            if (this.selectArray.indexOf("-1") > -1 && !this.allList[i].deptIds && !this.allList[i].roomId) {//未分配的
                this.treeData.push(this.allList[i]);
            } else if (this.allList[i].deptIds != "" && this.allList[i].roomId != "") {//诊室屏
                if (this.selectArray.indexOf(this.allList[i].roomId) > -1) {
                    this.treeData.push(this.allList[i]);
                }
            } else if (this.allList[i].deptIds != "" && !this.allList[i].roomId) {//科室屏
                let dArr = this.allList[i].deptIds.split(",");
                for (let j = 0; j < dArr.length; j++) {
                    if (this.selectArray.indexOf(dArr[j] + "|") > -1) {
                        this.treeData.push(this.allList[i]);
                    }
                }
            }
        }
        this.currentPage = 1;
        this.setShowList();
    }

    public updateTree() {
        let result: any = this.allList;
        this.propArray = [];
        let depts = this.depts;
        function getDeptById(deptId: string): IDeptModel {
            let dept: any;
            for (let i = 0; i < depts.length; i++) {
                if (depts[i].deptId == deptId) {
                    dept = depts[i];
                    break;
                }
            }
            return dept;
        }
        for (let i = 0; i < result.length; i++) {
            if (result[i].deptIds && result[i].roomId == "") {//科室屏
                let deptArr = result[i].deptIds.split(",");
                for (let j = 0; j < deptArr.length; j++) {
                    let boo = this.propArray.some(value => {
                        return value.id == deptArr[j];
                    })
                    if (boo) {
                        continue;
                    }
                    let d = getDeptById(deptArr[j])
                    if (d) {
                        let obj: any = {
                            label: d.deptName,
                            id: d.deptId,
                            children: [
                                {
                                    label: "科室屏",
                                    id: d.deptId + "|",
                                    children: [
                                    ],
                                }
                            ],
                        }
                        this.propArray.push(obj);
                    }
                }
            } else if (result[i].deptIds && result[i].roomId != "") {
                let deptArr = result[i].deptIds.split(",");
                for (let j = 0; j < deptArr.length; j++) {
                    let boo = this.propArray.some(value => {
                        return value.id == deptArr[j];
                    })
                    if (!boo) {
                        let d = getDeptById(deptArr[j])
                        if (d) {
                            let obj: any = {
                                label: d.deptName,
                                id: d.deptId,
                                children: new Array<any>(),
                            }
                            this.propArray.push(obj);
                        }
                    }
                    for (let k = 0; k < this.propArray.length; k++) {
                        if (deptArr[j] == this.propArray[k].id) {
                            let obj: any = {
                                label: result[i].roomName,
                                id: result[i].roomId,
                                children: new Array<any>(),
                            }
                            this.propArray[k].children.push(obj)
                        }
                    }
                }
            } else {//没有分配的
                let boo = this.propArray.some(value => {
                    return value.id == "-1";
                })
                if (boo) continue;
                let obj: any = {
                    label: '未分配',
                    id: "-1",
                    children: [],
                }
                this.propArray.push(obj);
            }
        }
    }

}

</script>

<style lang="scss">
.dRootCls {
    display: flex;
    flex-direction: row;
}

.dRootCls .div1 {
    width: 250px;
    height: 100%;
}

.dRootCls .div2 {
    flex: 1;
}


.more-class {
    display: flex;
    align-items: center;
    justify-content: center;
}

.editDialogClass {
    width: calc(100%);
    height: calc(100%);
}

.yulanRoot {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 5px,
}

.yulanRoot .centerClass {
    width: 100%;
    flex: 3;
    display: flex;
    gap: 8px;
    flex-direction: row;
}

.yulanRoot .centerClass .common {
    border-radius: 5px;
    margin-top: 5px;
    margin-bottom: 5px;
}

.yulanRoot .centerClass .leftClass {
    flex: 3;
    margin-left: 8px;
}

.left_data_class {
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: center;
    text-align: center;
}

.left_data_class>div {
    flex: 1;
}


.yulanRoot .centerClass .rightClass {
    flex: 1;
    margin-right: 8px;
}
</style>
